package com.heima.user.controller.v1;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.heima.model.user.pojo.ApUserFollow;
import com.heima.user.service.ApUserFollowService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@Api("用户关注管理API")
@RestController
@RequestMapping("/api/v1/user_follow")
public class ApUserFollowController {
  @Autowired ApUserFollowService apUserFollowService;

  @ApiOperation("查询是否关注过指定用户")
  @GetMapping("/one")
  public ApUserFollow findByUserIdAndFollowId(
      @RequestParam("userId") Integer userId, @RequestParam("followId") Integer followId) {
    return apUserFollowService.getOne(
        Wrappers.<ApUserFollow>lambdaQuery()
            .eq(ApUserFollow::getFollowId, followId)
            .eq(ApUserFollow::getUserId, userId));
  }
}
